package com.shenyong.ladmin.controller;

import com.shenyong.ladmin.entity.Article_Dianzan;
import com.shenyong.ladmin.logConfig.Log;
import com.shenyong.ladmin.logConfig.OperationType;
import com.shenyong.ladmin.result.Page;
import com.shenyong.ladmin.service.Article_DianZanService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 后台点赞管理
 * article_DianZanAll
 * deleteDianZan
 */
@RestController
public class Article_DianZanController {
    @Autowired
    private Article_DianZanService article_dianZanService;
    @RequiresAuthentication
    @ApiOperation(value = "查询点赞", notes = "分页查询点赞记录", produces = "application/json")
    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "起始行", required = false, dataType = "int")
            , @ApiImplicitParam(name = "limit", value = "显示多少条数据", required = false, dataType = "int")})
    @RequestMapping("article_DianZanAll")
    public Map<String,Object> article_DianZanAll(Page page){
        Map<String,Object> map = new HashMap<String, Object>();
        map.put("msg","");
        map.put("code",0);
        map.put("count",article_dianZanService.articleDianZanCount(page));
        map.put("data",article_dianZanService.articleDianZanAll(page));
        return map;
    }
    @RequiresAuthentication
    @ApiOperation(value = "移除点赞", notes = "删除单个点赞记录", produces = "application/json")
    @ApiImplicitParams(@ApiImplicitParam(name = "articleclick_id", value = "点赞Id", required = false, dataType = "int"))
    @Log(describe = "移除点赞",operationType= OperationType.DELETE)
    @RequestMapping("deleteDianZan")
    public int deleteComment(int articleclick_id){
        return article_dianZanService.deleteDianZan(articleclick_id);
    }
    @RequestMapping("DianAll")
    public int DianAll(Article_Dianzan article_Dianzan) {
        return article_dianZanService.DianAll(article_Dianzan);
    }
    //查询文章点赞状况(有无数据)进行添加
    @RequestMapping("DianZanAll")
    public int DianZanAll(Article_Dianzan article_Dianzan) {
        return article_dianZanService.DianZanAll(article_Dianzan);
    }
}
